#include "m0wig.h"
#include "ui_m0wig.h"
#include <QDebug>
#include <QJsonArray>
#include <QJsonDocument>
#include <QJsonObject>
M0Wig::M0Wig(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::M0Wig)
{
    ui->setupUi(this);
}

M0Wig::~M0Wig()
{
    delete ui;
}

void M0Wig::dataUpSlot(const QByteArray &msg)
{
    qDebug()<<"[M0]:enter M0 dataUpSlot";
    qDebug()<<"[M0]:msg:"<<msg;

    QJsonDocument doc = QJsonDocument::fromJson(msg);
    if(!doc.isObject())
    {
        qDebug()<<"[M0]:error json";
        return;
    }

    QJsonObject obj = doc.object();
    QJsonValue temp = obj["temp"];
    if(temp.isNull())
    {
        qDebug()<<"[M0]:no key:temp";
        return;
    }

    ui->lcdNumber->display(temp.toDouble());
}


